﻿<UserControl x:Class="PicturePortfolio.Silverlight.Views.CategoryListView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:ca="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro"
    xmlns:self="clr-namespace:PicturePortfolio.Silverlight"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400" Width="130">
    <UserControl.Resources>
        <self:ByteToImageConverter x:Name="byteToImageConv"></self:ByteToImageConverter>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" BorderThickness="0" Background="Transparent">
            <ListBox x:Name="Categories" VerticalAlignment="Stretch" BorderThickness="0" Background="Transparent" HorizontalAlignment="Stretch" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="SelectionChanged">
                        <ca:ActionMessage MethodName="CategorySelectionChanged">
                            <ca:Parameter Value="{Binding ElementName=Categories,Path=SelectedItem}"></ca:Parameter>
                        </ca:ActionMessage>
                    </i:EventTrigger>
                </i:Interaction.Triggers>
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Vertical" HorizontalAlignment="Center"></StackPanel>
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Border BorderBrush="Gray" 
							    BorderThickness="0" 
							    CornerRadius="0" 
							    Background="Transparent" Height="102" Width="102" Margin="2">
                            <StackPanel Orientation="Vertical">
                            <TextBlock x:Name="category" Text="{Binding CategoryName}" Foreground="White" Margin="2,0,0,0"></TextBlock>
                            <Image x:Name="thumbNail"  Width="100" Height="90" VerticalAlignment="Center" Source="{Binding CategoryThumbNail,Converter={StaticResource byteToImageConv}}"></Image>
                            </StackPanel>
                        </Border>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </ScrollViewer>
    </Grid>
</UserControl>
